function closePanel(errorElement, panel) {
    if (document.getElementById(errorElement) == null) {
        Richfaces.hideModalPanel(panel);
    }
}

function selectAllCheckBoxes(formName, tableName, q) {
    var nameSufix = ":sbcID";
    var pa = parseInt(document.getElementById(formName + ":" + tableName + ":ihPagina").value);
    
    for(i = 0; i < q; i++) {
        if (document.getElementById(formName + ":" + tableName + ":" + (((pa * q) - q) + i) + nameSufix).checked) {
            document.getElementById(formName + ":" + tableName + ":" + (((pa * q) - q) + i) + nameSufix).checked = false;
        } else {
            document.getElementById(formName + ":" + tableName + ":" + (((pa * q) - q) + i) + nameSufix).checked = true;
        }
    }
}

function calcularRisco(linha, coluna) {
    document.getElementById('tr' + linha).style.backgroundColor = 'darkRed';
    document.getElementById('tr' + linha).style.textAlign = 'center';
    document.getElementById('tr' + linha).style.color = '#fff';
    document.getElementById('tr' + linha).style.fontSize = '12pt';
    document.getElementById('tr' + linha).style.fontWeight = 'bold';

    document.getElementById('tc' + coluna).style.backgroundColor = 'darkRed';
    document.getElementById('tc' + coluna).style.textAlign = 'center';
    document.getElementById('tc' + coluna).style.color = '#fff';
    document.getElementById('tc' + coluna).style.fontSize = '12pt';
    document.getElementById('tc' + coluna).style.fontWeight = 'bold';
  
    document.getElementById('td' + linha + 'x' + coluna).style.backgroundColor = 'darkRed';
    document.getElementById('td' + linha + 'x' + coluna).style.textAlign = 'center';
    document.getElementById('td' + linha + 'x' + coluna).style.color = '#fff';
    document.getElementById('td' + linha + 'x' + coluna).style.fontSize = '18pt';
    document.getElementById('td' + linha + 'x' + coluna).style.fontWeight = 'bold';
    document.getElementById('td' + linha + 'x' + coluna).style.border = '4px solid black';  
  
    return false;
}

function marcarAbaAtual() {
    if (document.getElementById('ihNomePagina') != null) {
        var np = document.getElementById('ihNomePagina').value.toString().split('_');

        if (document.getElementById(np[0]) != null) {
            document.getElementById(np[0]).className='current';
        }
    }
}

function exibirToolbarAbaAtual() {
    if (document.getElementById('ihNomePagina') != null) {
        var np = document.getElementById('ihNomePagina').value.toString().split('_');

        if (document.getElementById(np[0]) != null) {
            if (document.getElementById('toolbar' + np[0]) != null) {
                document.getElementById('toolbar' + np[0]).style.visibility = 'visible';
            }
        }
    }
}

function highlightOpcaoAtualToolbar() {
    if (document.getElementById('ihNomePagina') != null) {
        var np = document.getElementById('ihNomePagina').value;
    
        if (np.toString().indexOf('_', 0) != -1) {
            document.getElementById('ftb:' + np).style.color = 'yellow';
            document.getElementById('ftb:' + np).style.fontWeight = 'bold';
            document.getElementById('ftb:' + np).style.marginLeft = '0px';
        }
    }
}

function ajaxRequestContainsErrors() {
    return document.getElementById("maximumSeverity").value == "2";
}


function jq(myid) {
    return '#'+myid.replace(/:/g,"\\:").replace(/\./g,"\\.");
}
